package com.sinodata.bsm.inmp.util;

import java.util.Hashtable;

/**
 *
 * <p>
 * Description: 缓存系统配置
 * </p>
 *
 * @author wangyz
 * @version 3.1

 * <p>
 * History:
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * Dec 12, 2011 5:18:58 PM          wangyz        3.1         To create
 * </p>
 *
 * @since
 * @see
 */
public class SystemContext {

    private static Hashtable<Object, Object> ummProperties = new Hashtable<Object, Object>();

    /**
     * 获取本地配置属性值，用户使用时向下转型。
     *
     * @param key
     *            Object
     * @return Object
     */
    public static Object getProperty(Object key) {
        return ummProperties.get(key);
    }

    /**
     * 获取本地配置属性值，用户使用时向下转型
     *
     * @param key
     *            Object
     * @return Object
     */
    public static Object getProperty(Object key, Object defaultVal) {
        Object result = ummProperties.get(key);
        return (result != null ? result : defaultVal);
    }

    /**
     * 子系统初始化时根据本地的配置文件调用该方法初始化本地配置类
     *
     * @param key
     *            Object
     * @param value
     *            Object
     */
    public static void setProperty(Object key, Object value) {
        if (key != null && value != null) {
            ummProperties.put(key, value);
        }
    }
}
